/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dp.view;

import com.dp.controller.WelcomeController;
import com.dp.dto.WelcomeDTO;
import com.dp.utils.BaseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Onur
 */
public class Welcome extends AbstractPage<WelcomeDTO> {

    /**
     * Creates new form Welcome
     */
    public Welcome() {
        initComponents();
        
        getStatistics();
    }
    
    private void getStatistics() {
        
        try {
            WelcomeController.getItemStatistics(dto);
            
            txtTotalBookNumber.setText(dto.getTotalBook()+"");
            txtTotalArticleNumber.setText(dto.getTotalArticle()+"");
            txtNationalBookNumber.setText(dto.getNationalBook()+"");
            txtInternationalBookNumber.setText(dto.getInterNationalBook()+"");
            txtNationalArticleNumber.setText(dto.getNationalArticle()+"");
            txtInternationalArticleNumber.setText(dto.getInterNationalArticle()+"");
            
        } catch (BaseException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        txtBookNumber = new javax.swing.JLabel();
        txtArticleNumber = new javax.swing.JLabel();
        txtTotalBookNumber = new javax.swing.JLabel();
        txtTotalArticleNumber = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtInternationalBookNumber = new javax.swing.JLabel();
        txtInternationalArticleNumber = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtNationalBookNumber = new javax.swing.JLabel();
        txtNationalArticleNumber = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(234, 243, 248));

        jLabel1.setText("Welcome to Publication Record Application!");

        txtBookNumber.setText("Book records:");

        txtArticleNumber.setText("Journal article records:");

        txtTotalBookNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtTotalBookNumber.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        txtTotalBookNumber.setText("0");

        txtTotalArticleNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtTotalArticleNumber.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        txtTotalArticleNumber.setText("0");

        jLabel2.setText("(International:");

        jLabel3.setText("(International:");

        txtInternationalBookNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtInternationalBookNumber.setText("0");

        txtInternationalArticleNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtInternationalArticleNumber.setText("0");

        jLabel8.setText(", National:");

        jLabel9.setText(", National:");

        txtNationalBookNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtNationalBookNumber.setText("0");

        txtNationalArticleNumber.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtNationalArticleNumber.setText("0");

        jLabel12.setText(")");

        jLabel13.setText(")");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtBookNumber)
                            .addComponent(txtArticleNumber))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtTotalArticleNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTotalBookNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtInternationalBookNumber)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNationalBookNumber)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel12))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtInternationalArticleNumber)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNationalArticleNumber)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel13)))
                .addContainerGap(76, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(jLabel1)
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBookNumber)
                    .addComponent(txtTotalBookNumber)
                    .addComponent(jLabel2)
                    .addComponent(txtInternationalBookNumber)
                    .addComponent(jLabel8)
                    .addComponent(txtNationalBookNumber)
                    .addComponent(jLabel12))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtArticleNumber)
                    .addComponent(txtTotalArticleNumber)
                    .addComponent(jLabel3)
                    .addComponent(txtInternationalArticleNumber)
                    .addComponent(jLabel9)
                    .addComponent(txtNationalArticleNumber)
                    .addComponent(jLabel13))
                .addContainerGap(155, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel txtArticleNumber;
    private javax.swing.JLabel txtBookNumber;
    private javax.swing.JLabel txtInternationalArticleNumber;
    private javax.swing.JLabel txtInternationalBookNumber;
    private javax.swing.JLabel txtNationalArticleNumber;
    private javax.swing.JLabel txtNationalBookNumber;
    private javax.swing.JLabel txtTotalArticleNumber;
    private javax.swing.JLabel txtTotalBookNumber;
    // End of variables declaration//GEN-END:variables
}
